<template>
  <div class="updateDesc_wrapper">
    <div class="ue">
      <div class="mng">
        <img
          class="mmg"
          src="../../assets/images/icon_h1h6rlt6v8d/zuojiantou7.png"
          mode=""
          @click="imaged"
        />
        <div class="conten_tit">
          <div class="tit_date">
            <p>体检编号</p>
            <input
              type="text"
              v-model="user.Get_CheckSub_Data1.Check_No"
              :disabled="isDisabled"
            />
          </div>
          <div class="tit_date">
            <p>体检日期</p>
            <input
              type="text"
              v-model="user.Get_CheckSub_Data1.Check_Date"
              :disabled="isDisabled"
            />
          </div>
          <div class="tit_date">
            <p>姓名</p>
            <input
              type="text"
              v-model="user.Get_CheckSub_Data1.Pson_Name"
              :disabled="isDisabled"
            />
          </div>
          <div class="tit_date">
            <p>年龄</p>
            <input
              type="text"
              v-model="user.Get_CheckSub_Data1.Pson_Age"
              :disabled="isDisabled"
            />
          </div>
          <div class="tit_date">
            <p id="tp">身份证</p>
            <input
              type="text"
              id="te"
              v-model="user.Get_CheckSub_Data1.Pson_CardID"
              :disabled="isDisabled"
            />
          </div>
          <div class="tit_date">
            <p id="tm">人群类型</p>
            <input
              type="text"
              v-model="user.Get_CheckSub_Data1.Pson_Type"
              :disabled="isDisabled"
            />
          </div>
          <div class="tit_date">
            <p>BMI</p>
            <input
              type="text"
              v-model="user.Get_CheckSub_Data1.Sub_Bmi"
              :disabled="isDisabled"
            />
          </div>
          <div class="tit_date">
            <p id="tt">腹围</p>
            <input
              type="text"
              v-model="user.Get_CheckSub_Data1.Sub_Waistline"
              :disabled="isDisabled"
            />
          </div>
          <!-- <div class="tit_date" ><p>电话号码</p><input type="text" :disabled=isDisabled></div> -->
        </div>
      </div>
    </div>
    <div class="updateDesc_con">
      <div class="update_right">
        <div class="update_conten">
          <div class="conten_info">
            <div class="content_wrapper" ref="content_wrapper">
              <div v-for="(u, i) in ue" :key="u.Tz_Id">
                <div>
                  <div
                    v-for="(item, index) in u"
                    :key="item.Que_ID"
                    class="roll_box"
                    :ref="`cont_${index + 1}`"
                    :id="`${item.Que_ID}roll_box`"
                  >
                    <div class="con_tit">
                      <div
                        class="con_title"
                        v-if="index === 0"
                        :style="{
                          backgroundColor: isError(u[0].Tz_Name) ? 'red' : '',
                        }"
                      >
                        {{ u[0].Tz_Name }}
                      </div>
                      <div
                        v-if="isError(u[0].Tz_Name)"
                        :style="{ color: isError(u[0].Tz_Name) ? 'red' : '' }"
                      >
                        *请重新选择下列体质内选项
                      </div>
                      {{ index + 1 }}.{{ item.Que_Name }}{{ item.Que_Remark }}
                      <van-radio-group
                        v-model="user.optionser[i][index].Opt_ID"
                        class="question-container"
                      >
                        <van-cell-group
                          v-for="option in getUserPosts(item)"
                          :key="option.Que_ID"
                          clickable
                        >
                          <van-radio
                            :name="`${option.Opt_ID}`"
                            @click="onuser(option.Opt_Score, option.Que_ID)"
                            border
                            >{{ option.Opt_Name }}</van-radio
                          >
                        </van-cell-group>
                      </van-radio-group>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="update_tab">
          <div class="ub">
            <div v-for="(item, index) in this.dd" :key="index" class="bsn">
              <p class="ppp">{{ item[0].Tz_Name }}</p>
              <button
                v-for="(u, index1) in item"
                :key="index1"
                @click="scrollTo(u.Que_ID)"
                :class="{
                  tab: true,
                  active: activeTab == u.Que_ID,
                  isactive: isErrors(u.Tz_Id),
                }"
              >
                {{ index1 + 1 }}
              </button>
            </div>
          </div>
          <div class="bt">
            <button class="tj" :disabled="isButtonDisabled" @click="send">
              计算评分
            </button>
            <!-- <button class="tj1" @click="bc">保存</button> -->
          </div>
          <div v-if="this.user.yclist.length > 3" class="yc">
            <div v-for="item in this.user.yclist" :key="item.RankNo">
              <div class="yc-title">
                <p class="pp">
                  {{ item.RankNo }}{{ item.Tz_Name }}({{ item.Rlt_Score }}分)
                </p>
                <a v-if="item.Err_Tag === 1">(异常)</a>
              </div>
            </div>
            <div class="bn">
              <button class="tj2" @click="yc">自动纠错</button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { userStore } from "../../stores/user.ts";
// const VITE_API_URL=import.meta.env.VITE_API_URL
import { ElMessageBox, ElMessage } from "element-plus";
export default {
  name: "update-desc",
  components: {},
  data() {
    return {
      user: "",
      isScrollNow: "0",
      User_Code: "",
      Interface_Code: "",
      wtlist: [],
      xxlist: [],
      lists: [],
      File: [],
      keepField: "Que_ID",
      keepField2: "Rlt_OptId",
      keepField3: "Opt_Score",
      isDisabled: true,
      chex: "",
      ue: "",
      dd: "",
      dds: "",
      mms: "",
      mm: "",
      b: true,
      n: 1,
      sss: "",
      list: [],
      yclist: [],
      errorValue: [],
      yyy: "",
      yyys: "",
      cc: [],
      ccs: "",
      activeTab: "",
      code: "",
      isButtonDisabled: false,
      q1:'',
      q2:'',
      q3:''
    };
  },
  mounted() {
    // this.getyclist()
    // this.getyc()
    window.addEventListener("scroll", this.onScroll, true);
    console.log(this.user.optionser);
  },
  beforeDestroy() {
    document.removeEventListener("scroll", this.onScroll, false);
  },
  created() {
    this.Interface_Code = sessionStorage.getItem("item");
    this.User_Code = JSON.parse(sessionStorage.getItem("UserInfo")).sUser_Code;
    this.user = userStore();
    this.code = this.$route.query.code;
    // this.user.restoreState()
    console.log(this.user.sex);
    this.user.optionser = JSON.parse(sessionStorage.getItem("file"));
    this.user.yclist = JSON.parse(sessionStorage.getItem("yc"))
      ? JSON.parse(sessionStorage.getItem("yc"))
      : [];
    window.addEventListener("scroll", this.onScroll, true);
    this.getzytz();
    console.log("ccccccccnm", this.ue);
  },
  computed: {
    getUserPosts() {
      return (wt) => {
           console.log("bbccdd",wt)
        return this.lists.filter((list) => list[0].Que_ID === wt.Que_ID)[0];
      };
    }
  },
  beforeUnmount() {
    this.user.saveState();
  },
  methods: {
     getUserPosts1(wt) {
      console.log("xxxggg",wt)
        return this.lists.filter((list) => list[0].Que_ID === wt)[0]
    },
    //中医体质倒推选项信息
    ZytzQuestions() {
      if (this.code == 1) {
        this.user.ZytzQuestions.forEach((item) => {
          this.dd.forEach((item1) => {
            item1.forEach((item2) => {
              if (item.Que_ID == item2.Que_ID) {
                item2.Opt_Score = item.Opt_Rank;
                item2.Opt_ID = item.Rlt_OptId;
              }
            });
          });
        });
      }
      sessionStorage.setItem("file", JSON.stringify(this.dd));
    },
    imaged() {
      this.$router.push("/souye");
    },
    istab(tab) {
      this.wtlist.forEach((item) => {
        if (item.Que_ID === tab) {
          console.log("123");
          return true;
        }
      });
    },
    bc() {
      axios
        .post(
          window.globalUrl.server + "Service.asmx/Zytz_Result_Delete",
          JSON.stringify({
            User_Code: this.User_Code,
            Interface_Code: this.Interface_Code,
            Check_No: this.user.Get_CheckSub_Data1.Check_No,
          })
        )
        .then((res) => {
          console.log(res);
        });
    },
    send() {
      this.isButtonDisabled = true;
      this.flattenedData();
      this.rmovesss();
      console.log("888");
      console.log(this.sss);
      this.user.optionser.forEach((item, index1) => {
        // ElMessage.error({message:`检测到您${item[0].Tz_Name}第${index+1}题尚未作答,请认真检查`})
        console.log(item);

        item.forEach((item1) => {
          if (item1.Opt_ID.trim() == "" && item1.Opt_Score.trim() == "") {
            ElMessage.error({
              message: `检测到您${item[0].Tz_Name}第${
                index1 + 1
              }题尚未作答,请认真检查`,
            });
          }
        });
      });
      axios
        .post(
          window.globalUrl.server + "Service.asmx/Zytz_Quetions_Submit",
          JSON.stringify({
            User_Code: this.User_Code,
            Interface_Code: this.Interface_Code,
            Check_No: this.user.Get_CheckSub_Data1.Check_No,
            Pson_Name: this.user.Get_CheckSub_Data1.Pson_Name,
            Pson_Age: this.user.Get_CheckSub_Data1.Pson_Age,
            Pson_Sex: this.user.Get_CheckSub_Data1.Pson_Sex,
            Check_Date: this.user.Get_CheckSub_Data1.Check_Date,
            Pson_Tel: this.user.Get_CheckSub_Data1.Pson_Tel,
            Pson_CardID: this.user.Get_CheckSub_Data1.Pson_CardID,
            Pson_Addr: this.user.Get_CheckSub_Data1.address,
            Pson_Tag: this.user.Get_CheckSub_Data1.Pson_Tag,
            Check_Package: "",
            Que_list: JSON.stringify(this.sss),
          })
        )
        .then((res) => {
          console.log(res);
          if (res.data.RltCode === 1) {
            this.isButtonDisabled = false;
            axios
              .post(
                window.globalUrl.server + "/Service.asmx/GetZytz_Sums_Result",
                JSON.stringify({
                  User_Code: this.User_Code,
                  Interface_Code: this.Interface_Code,
                  Check_No: this.user.Get_CheckSub_Data1.Check_No,
                  Pson_Name: this.user.Get_CheckSub_Data1.Pson_Name,
                  Pson_Age: this.user.Get_CheckSub_Data1.Pson_Age,
                  Pson_Sex: this.user.Get_CheckSub_Data1.Pson_Sex,
                  Check_Date: this.user.Get_CheckSub_Data1.Check_Date,
                  Pson_Tel: this.user.Get_CheckSub_Data1.Pson_Tel,
                  Pson_CardID: this.user.Get_CheckSub_Data1.Pson_CardID,
                  Pson_Addr: this.user.Get_CheckSub_Data1.address,
                  Pson_Tag: this.user.Get_CheckSub_Data1.Pson_Tag,
                  Check_Package: "",
                })
              )
              .then((res) => {
                console.log(res);
                console.log("999");
                console.log(JSON.parse(res.data.RltData));
                if (res.data.RltCode === 1) {
                  this.showLoadings();
                  this.yclist = JSON.parse(res.data.RltData);
                  if (this.yclist.length > 3) {
                    if (
                      this.yclist.length == 4 &&
                      this.yclist[3].Tz_Name == "平和质"
                    ) {
                      this.$router.push("/output");
                    } else if (
                      this.yclist.length == 4 &&
                      this.yclist[3].Tz_Name == "痰湿质"
                    ) {
                      alert("当前结果不符合中医体质辨识评价规则，请重新评估");
                    }
                    // this.yclist=JSON.parse( sessionStorage.getItem("yc"))?JSON.parse( sessionStorage.getItem("yc")):this.yclist
                    sessionStorage.setItem("yc", JSON.stringify(this.yclist));
                    this.user.yclist = this.yclist;
                    this.getyclist();
                    this.getyc();
                    this.getyclists();
                    this.getycs();
                  } else if (this.yclist.length <= 3) {
                    // this.yclist=JSON.parse( sessionStorage.getItem("yc"))?JSON.parse( sessionStorage.getItem("yc")):this.yclist
                    sessionStorage.setItem("yc", JSON.stringify(this.yclist));
                    this.user.yclist = this.yclist;
                    if (this.yclist.length === 1) {
                      this.$router.push("/output");
                    } else {
                      this.$router.push("/output");
                    }
                  }
                }
              });
          }
        })
        .catch((eorro) => {
          console.log(eorro);
        });
    },
    onuser(option1, option2, option3) {
      this.user.optionser.map((item) => {
        item.map((item1) => {
          if (item1.Que_ID == option2) {
            item1.Opt_Score = option1;
          }
        });
      });
      sessionStorage.setItem("file", JSON.stringify(this.user.optionser));
    },

    removeExtraFields() {
      this.dds = this.wtlist.map((item) => ({
        [this.keepField]: item[this.keepField],
        [this.keepField2]: item[this.keepField2],
        Opt_Score: "",
        User_Code: this.User_Code,
        Interface_Code: this.Interface_Code,
        Check_No: "01",
        Tz_Id: item["Tz_Id"],
        Tz_Name: item["Tz_Name"],
        Opt_ID: "",
      }));
      this.mms = this.wtlist.map((item) => ({
        [this.keepField]: item[this.keepField],
        [this.keepField2]: item[this.keepField2],
        Opt_Score: "",
        User_Code: this.User_Code,
        Interface_Code: this.Interface_Code,
        Check_No: "01",
        Tz_Id: item["Tz_Id"],
        Tz_Name: item["Tz_Name"],
        Opt_ID: "",
      }));
    },
    rmovesss() {
      this.sss = this.list.map((item) => ({
        [this.keepField]: item[this.keepField],
        [this.keepField2]: item[this.keepField2],
        Rlt_Score: item["Opt_Score"],
        Rlt_OptId: item["Opt_ID"],
      }));
    },
    getyc() {
      this.yyy = this.cc[1].map((item) => item.Tz_Name);
    },
    getycs() {
      this.yyys = this.user.yclist.slice(3).map((item) => item.Tz_Id);
      console.log(this.user.yclist);
      console.log(this.yyys);
    },
    flattenedData() {
      var list = [];
      this.user.optionser.forEach((item) => {
        item.forEach((item1) => {
          list.push(item1);
          this.list = list;
          console.log(this.list);
        });
      });
    },
    getyclist() {
      var obj2 = {},
        newArr2 = [];
      this.user.yclist.forEach(function (item, suffix) {
        //根据对象的属性是唯一的，将值作为对象的属性名
        if (!obj2[item.Err_Tag]) {
          var arr2 = [];
          arr2.push(item);
          newArr2.push(arr2);
          obj2[item.Err_Tag] = item;
        } else {
          newArr2.forEach(function (value, index) {
            //如果已经存在  就循环新组的值将值插入属性相同的数组里   为了防止重复添加   只要和第一个比较就可以了
            if (value[0].Err_Tag == item.Err_Tag) {
              value.push(item);
            }
          });
        }
      });
      this.cc = newArr2;
    },
    getyclists() {
      var obj4 = {},
        newArr4 = [];
      this.user.yclist.forEach(function (item, suffix) {
        //根据对象的属性是唯一的，将值作为对象的属性名
        if (!obj4[item.Tz_Id]) {
          var arr4 = [];
          arr4.push(item);
          newArr4.push(arr4);
          obj4[item.Tz_Id] = item;
        } else {
          newArr4.forEach(function (value, index) {
            //如果已经存在  就循环新组的值将值插入属性相同的数组里   为了防止重复添加   只要和第一个比较就可以了
            if (value[0].Tz_Id == item.Tz_Id) {
              value.push(item);
            }
          });
        }
      });
      this.ccs = newArr4;
    },
    getMM() {
      var obj1 = {},
        newArr1 = [];
      this.mms.forEach(function (item, suffix) {
        //根据对象的属性是唯一的，将值作为对象的属性名
        if (!obj1[item.Tz_Id]) {
          var arr1 = [];
          arr1.push(item);
          newArr1.push(arr1);
          obj1[item.Tz_Id] = item;
        } else {
          newArr1.forEach(function (value, index) {
            //如果已经存在  就循环新组的值将值插入属性相同的数组里   为了防止重复添加   只要和第一个比较就可以了
            if (value[0].Tz_Id == item.Tz_Id) {
              value.push(item);
            }
          });
        }
      });
      this.mm = newArr1;
    },
    //bmi,腹围初始赋值
    getbmi() {
      if (this.code == "0") {
        console.log("xjb");
        console.log(this.dd);
        this.dd.forEach((item) => {
          item.forEach((item1) => {
            if (item1.Que_ID == "1") {
             const q1=this.getUserPosts1(item1.Que_ID)
              if (
                Number(this.user.Get_CheckSub_Data1.Sub_Bmi) < 24 &&
                this.user.Get_CheckSub_Data1.Sub_Bmi.trim() !== ""
              ) {
                console.log("bmi1",q1[0].Opt_ID)
                item1.Opt_ID = q1[0].Opt_ID+"";
                item1.Opt_Score = 1;
              } else if (
                Number(
                  this.user.Get_CheckSub_Data1.Sub_Bmi < 25 &&
                    this.user.Get_CheckSub_Data1.Sub_Bmi
                ) >= 24 &&
                this.user.Get_CheckSub_Data1.Sub_Bmi.trim() !== ""
              ) {
                 console.log("bmi2",q1[0].Opt_ID)
                item1.Opt_ID =  q1[1].Opt_ID+'';
                item1.Opt_Score = 2;
              } else if (
                Number(
                  this.user.Get_CheckSub_Data1.Sub_Bmi < 26 &&
                    this.user.Get_CheckSub_Data1.Sub_Bmi
                ) >= 25 &&
                this.user.Get_CheckSub_Data1.Sub_Bmi.trim() !== ""
              ) {
                 console.log("bmi3",q1[0].Opt_ID)
                item1.Opt_ID = q1[2].Opt_ID+'';
                item1.Opt_Score = 3;
              } else if (
                Number(
                  this.user.Get_CheckSub_Data1.Sub_Bmi < 28 &&
                    this.user.Get_CheckSub_Data1.Sub_Bmi
                ) >= 26 &&
                this.user.Get_CheckSub_Data1.Sub_Bmi.trim() !== ""
              ) {
                 console.log("bmi4",q1[0].Opt_ID)
                item1.Opt_ID = q1[3].Opt_ID+'';
                item1.Opt_Score = 4;
              } else if (
                Number(
                  this.user.Get_CheckSub_Data1.Sub_Bmi >= 28 &&
                    this.user.Get_CheckSub_Data1.Sub_Bmi.trim() !== ""
                )
              ) {
                 console.log("bmi5",q1[0].Opt_ID)
                item1.Opt_ID = q1[4].Opt_ID+'';
                item1.Opt_Score = 5;
              }
              //  else if (this.user.Get_CheckSub_Data1.Sub_Bmi == "") {
              //   item1.Opt_ID = "";
              //   item1.Opt_Score = null;
              // }
            } else if (item1.Que_ID == "5") {
              const q2=this.getUserPosts1(item1.Que_ID)
              if (
                Number(this.user.Get_CheckSub_Data1.Sub_Waistline) < 80 &&
                this.user.Get_CheckSub_Data1.Sub_Waistline !== ""
              ) {
                item1.Opt_ID =q2[0].Opt_ID+"";
                item1.Opt_Score = 1;
              } else if (
                Number(this.user.Get_CheckSub_Data1.Sub_Waistline) <= 85 &&
                Number(this.user.Get_CheckSub_Data1.Sub_Waistline) >= 80 &&
                this.user.Get_CheckSub_Data1.Sub_Waistline !== ""
              ) {
                item1.Opt_ID = q2[1].Opt_ID+"";
                item1.Opt_Score = 2;
              } else if (
                Number(this.user.Get_CheckSub_Data1.Sub_Waistline) <= 90 &&
                Number(this.user.Get_CheckSub_Data1.Sub_Waistline) >= 86 &&
                this.user.Get_CheckSub_Data1.Sub_Waistline !== ""
              ) {
                item1.Opt_ID = q2[2].Opt_ID+"";
                item1.Opt_Score = 3;
              } else if (
                Number(this.user.Get_CheckSub_Data1.Sub_Waistline) <= 105 &&
                Number(this.user.Get_CheckSub_Data1.Sub_Waistline) >= 91 &&
                this.user.Get_CheckSub_Data1.Sub_Waistline !== ""
              ) {
                item1.Opt_ID = q2[3].Opt_ID+"";
                item1.Opt_Score = 4;
              } else if (
                Number(this.user.Get_CheckSub_Data1.Sub_Waistline) > 105 &&
                this.user.Get_CheckSub_Data1.Sub_Waistline !== ""
              ) {
                item1.Opt_ID = q2[4].Opt_ID+"";
                item1.Opt_Score = 5;
              }
              //  else if (this.user.Get_CheckSub_Data1.Sub_Waistline == "") {
              //   item1.Opt_ID = "";
              //   item1.Opt_Score = null;
              // }
            }
          });
        });
      }
      sessionStorage.setItem("file", JSON.stringify(this.dd));
    },
    getDD() {
      var obj1 = {},
        newArr1 = [];
      this.dds.forEach(function (item, suffix) {
        //根据对象的属性是唯一的，将值作为对象的属性名
        if (!obj1[item.Tz_Id]) {
          var arr1 = [];
          arr1.push(item);
          newArr1.push(arr1);
          obj1[item.Tz_Id] = item;
        } else {
          newArr1.forEach(function (value, index) {
            //如果已经存在  就循环新组的值将值插入属性相同的数组里   为了防止重复添加   只要和第一个比较就可以了
            if (value[0].Tz_Id == item.Tz_Id) {
              value.push(item);
            }
          });
        }
      });
      this.dd = newArr1;
    },
    getUe() {
      var obj1 = {},
        newArr1 = [];
      this.wtlist.forEach(function (item, suffix) {
        //根据对象的属性是唯一的，将值作为对象的属性名
        if (!obj1[item.Tz_Id]) {
          var arr1 = [];
          arr1.push(item);
          newArr1.push(arr1);
          obj1[item.Tz_Id] = item;
        } else {
          newArr1.forEach(function (value, index) {
            //如果已经存在  就循环新组的值将值插入属性相同的数组里   为了防止重复添加   只要和第一个比较就可以了
            if (value[0].Tz_Id == item.Tz_Id) {
              value.push(item);
            }
          });
        }
      });
      this.ue = newArr1;
    },
    onOptionChange(index, option) {
      console.log(option);
      this.user.updateOption(index, option);
    },
    defaultoptions() {
      if (this.code == "0") {
        console.log("ggggg", this.lists);
        this.user.optionser.forEach((item) => {
          console.log(item);
          item.forEach((item1) => {
            console.log("item1", item1);
            this.lists.forEach((item2) => {
              console.log("item2", item2);
              if (item1.Que_ID == item2[0].Que_ID && item1.Rlt_OptId == 0) {
                item1.Opt_ID = item2[0].Opt_ID + "";
                item1.Opt_Score = item2[0].Opt_Score;
              }
              if (item1.Que_ID == item2[0].Que_ID && item1.Rlt_OptId != 0) {
                item1.Opt_ID = item1.Rlt_OptId;
                let index = item2.findIndex(
                  (items) => items.Opt_ID == item1.Rlt_OptId
                );
                item1.Opt_Score = index + 1;
              }
              if (item1.Que_ID == "37" && item1.Rlt_OptId == "0") {
                const q3=this.getUserPosts1(item1.Que_ID)
                item1.Opt_ID =q3[4].Opt_ID+"" ;
                item1.Opt_Score = 5;
              }
            });
          });
        });
        sessionStorage.setItem("file", JSON.stringify(this.user.optionser));
      }
    },

    getzytz() {
      axios
        .post(
          window.globalUrl.server + "Service.asmx/GetZytzQuestions",
          JSON.stringify({
            User_Code: this.User_Code,
            Interface_Code: this.Interface_Code,
            Check_No: this.user.Get_CheckSub_Data1.Check_No,
            RankMode: "0",
          })
        )
        .then((res) => {
          this.wtlist = JSON.parse(res.data.RltData);
          this.getUe();
          // console.log("xbt",this.ue[0][0])
          console.log(this.wtlist);
          this.removeExtraFields();
          this.getDD();
          this.dd = JSON.parse(sessionStorage.getItem("file"))
            ? JSON.parse(sessionStorage.getItem("file"))
            : this.dd;
          // sessionStorage.setItem("file",JSON.stringify(this.dd))
          // this.getbmi();
          this.ZytzQuestions();
          console.log(this.dd);
          this.user.optionser = this.dd;
          axios
            .post(
              window.globalUrl.server + "Service.asmx/GetZytzQuestion_Options",
              JSON.stringify({
                User_Code: this.User_Code,
                Interface_Code: this.Interface_Code,
              })
            )
            .then((res) => {
              console.log(JSON.parse(res.data.RltData));
              this.xxlist = JSON.parse(res.data.RltData);
              var obj = {},
                newArr = [];
              this.list = this.xxlist.forEach(function (item, suffix) {
                //根据对象的属性是唯一的，将值作为对象的属性名
                if (!obj[item.Que_ID]){
                  var arr = [];
                  arr.push(item);
                  newArr.push(arr);
                  obj[item.Que_ID] = item;
                } else{
                  newArr.forEach(function (value, index) {
                    //如果已经存在  就循环新组的值将值插入属性相同的数组里   为了防止重复添加   只要和第一个比较就可以了
                    if (value[0].Que_ID == item.Que_ID){
                      value.push(item);
                    }
                  });
                }
              });
              console.log(obj);
              console.log(newArr);
              this.lists = newArr;
              this.defaultoptions();
              this.getbmi();
            });
        });
    },
    yc(){
      this.showLoading();
      if (this.user.yclist.length > 3) {
        this.user.optionser.forEach((item) => {
          this.user.yclist.slice(3).forEach((item1) => {
            if (item[0].Tz_Id === item1.Tz_Id) {
              item.forEach((item2) => {
                if (item2.Tz_Name == "痰湿质") {
                  if (item2.Opt_ID == "50" || item2.Opt_ID == "75") {
                    item2.Opt_ID = item2.Opt_ID;
                  } else {
                    item2.Opt_ID = this.getUserPosts(item2)[0].Opt_ID + "";
                  }
                } else if (item2.Tz_Name == "平和质") {
                  item2.Opt_ID = item2.Opt_ID;
                } else {
                  item2.Opt_ID = this.getUserPosts(item2)[0].Opt_ID + "";
                }
                console.log(item2.Opt_ID);
                console.log(this.getUserPosts(item2));
                // console.log(this.user.optionser)
              });
            }
          });
          sessionStorage.setItem("file", JSON.stringify(this.user.optionser));
        });
        // sessionStorage.setItem("file",JSON.stringify(this.user.optionser))
      }
    },
    showLoadings() {
      // 显示全屏Loading
      const loading = this.$loading({
        lock: true,
        text: "正在提交计算中...",
        background: "rgba(0, 0, 0, 0.7)",
      });

      // 假设你的异步操作
      setTimeout(() => {
        // 异步操作完成后关闭Loading
        loading.close();
      }, 1000);
    },
    showLoading() {
      // 显示全屏Loading
      const loading = this.$loading({
        lock: true,
        text: "自动纠错中...",
        background: "rgba(0, 0, 0, 0.7)",
      });

      // 假设你的异步操作
      setTimeout(() => {
        // 异步操作完成后关闭Loading
        loading.close();
      }, 1000);
    },
    isError(data) {
      // this.getyclist()
      // this.$nextTick(() => {
      //   this.getyc()
      // },100)
      // this.getyc()
      return this.yyy.includes(data);
    },
    isErrors(data, dat2) {
      console.log(data);
      return this.yyys.includes(data);
    },
    scrollTo(tab) {
      this.activeTab = tab;
      console.log(this.isScrollNow);
      console.log(tab);
      console.log(document.getElementById(`${tab}roll_box`));
      document.getElementById(`${tab}roll_box`).scrollIntoView({
        behavior: "smooth",
        block: "start",
      });
    },
    getScrollTop() {
      return (
        window.pageYOffset ||
        document.documentElement.scrollTop ||
        document.body.scrollTop
      );
    },

    // 内容部分滚动方法
    onScroll() {
      console.log(this.getScrollTop());
      const navContents = document.querySelectorAll(".roll_box");
      const offsetTopArr = [];
      navContents.forEach((item) => {
        offsetTopArr.push(item.offsetTop);
      });
      console.log(offsetTopArr);
      // console.log(navContents)
      let navIndex = 0;
      for (let n = 0; n < offsetTopArr.length; n++) {
        if (this.getScrollTop() >= offsetTopArr[n]) {
          navIndex = n + 1;
          this.isScrollNow = navIndex + "";
          console.log(this.isScrollNow);
          // 滑动底部选中最后一个选项
          if (
            this.getScrollTop().scrollHeight -
              this.$refs.content_wrapper.scrollTop <=
            this.$refs.content_wrapper.clientHeight + 50
          ) {
            this.isScrollNow = String(offsetTopArr.length - 1);
          }
        }
      }
    },
  },
};
</script>

<style scoped>
#tm {
  /* margin-right: -2px; */
}
.mmg {
  width: 40px;
  height: 40px;
}
.mng {
  display: flex;
  align-items: center;
}
.ppp {
  font-size: 14px;
  margin-right: 4px;
  margin-left: 4px;
}
.bsn {
  width: 100%;
  height: 23px;
  display: flex;
  align-items: center;
  /* padding: 5px 0px; */
}
.error {
  background-color: #885a43;
}
.bn {
  display: flex;
  justify-content: center;
}
.yc-title {
  display: flex;
  justify-content: center;
  align-items: center;
}
.yc-title > a {
  color: red;
}
.yc {
  width: 100%;
}
.bt {
  display: flex;
}
.con_title {
  background-color: #fff;
  height: 50px;
  font-size: 26px;
  display: flex;
  justify-content: center;
  align-items: center;
}
::v-deep .van-radio__icon--checked .van-icon {
  color: var(--van-white);
  background-color: #885a43;
  border-color: var(--van-radio-checked-icon-color);
}
::v-deep .van-radio__icon--round .van-icon {
  border-radius: 100%;
  border: 1px solid black;
}
::v-deep .van-radio {
  background-color: #efeade;
}
.updateDesc_wrapper {
  height: 100%;
}
.is-danger {
  background-color: red;
}
.is-success {
  background-color: green;
}
.updateDesc_con {
  /* display: flex; */
  justify-content: space-between;
  background-color: #efeade;
  height: 100%;
}
.update_left {
  width: 240px;
  border-right: 1px solid rgba(229, 230, 235, 0.7);
}
.update_img {
  width: 100%;
}
.updateImg {
  width: 100%;
}

.update_menu {
  width: 100%;
}
/deep/ .updateMenu {
  border-right: none;
}
.el-submenu__title {
  padding: 0 !important;
  padding-left: 40px !important;
  text-align: left;
  color: #1d2128;
  height: 40px;
  line-height: 40px;
}

.el-menu-item-group__title {
  display: none;
}

.el-submenu__icon-arrow {
  color: transparent;
  background: url(../../assets/image/update-desc/updateIcon3.png) no-repeat;
  background-size: contain;
  position: absolute;
  top: 50%;
  right: inherit;
  left: 25px;
  margin-top: -5px;
  font-size: 14px;
  display: block;
  width: 8px;
}

.el-submenu.is-opened > .el-submenu__title .el-submenu__icon-arrow {
  transform: rotateZ(90deg);
}

.el-submenu .el-menu-item {
  height: 32px;
  line-height: 32px;
  border-left: 2px solid #fff;
  padding: 0 20px 0 40px !important;
  text-align: left;
}
img {
  width: 11px;
}

.img2 {
  display: none;
}

span {
  font-size: 12px;
  color: #1d2128;
  margin-left: 10px;
}

.isactive {
  background-color: red !important;
  border-left: 2px solid #2d5cf6;
}
.img1 {
  display: none;
}

.img2 {
  display: inline;
}

span {
  color: #2d5cf6;
}
.update_right {
  width: calc(100% - 300px);
  height: 100%;
  display: flex;
  justify-content: space-between;
}
.update_conten {
  width: 100%;
  height: 9360px;
  overflow-y: hidden;
  padding: 0px 30px;
  box-sizing: border-box;
}
.conten_tit {
  display: flex;
  height: 75px;
  /* justify-content: space-between;
            a
            lign-items: center; */
  width: 100%;
  flex-wrap: wrap;
  /* border-bottom: 1px solid #E5E6EB; */
  flex-direction: column;
}
.tit_text {
  font-weight: 700;
  font-size: 20px;
  line-height: 28px;
  color: #1d2128;
}

.tit_date {
  font-size: 14px;
  line-height: 22px;
  color: #86909c;
  /* margin-left: 60px; */
  display: flex;
  margin-top: 8px;
}

.conten_info {
  width: 100%;
}
.content_wrapper {
}
.roll_box {
  text-align: left;
  /* height: 250px; */
  padding-top: 75px;
}
.con_tit {
  /* padding-top: 75px; */
  font-weight: 700;
  font-size: 16px;
  line-height: 24px;
  color: #885a43;
  position: relative;
}
.content_wrapper::before {
  content: "";
  position: absolute;
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  left: -6px;
  top: 0px;
  background: linear-gradient(
    90deg,
    rgba(123, 97, 255, 0.3) 0%,
    rgba(97, 160, 255, 0.3) 107.5%
  );
}

.con_info {
}
::v-deep .pp {
  font-size: 14px;
}
.con_info p {
  font-size: 14px;
  line-height: 22px;
  margin-top: 16px;
  color: #1d2128;
}
.con_info img {
  width: 100%;
  margin-top: 16px;
}

/* .update_tab {
          width: 240px;
          padding-top: 16px;
        } */
/deep/ .updateTab .el-tabs__header {
  float: left;
  text-align: left;
  /* position: fixed;
              top:70px;
              right: 0; */
}

a {
  font-size: 14px;
}
.el-tabs__nav {
  float: none !important;
}

.el-tabs__item {
  font-size: 14px;
  color: #86909c;
}

::v-deep .el-tabs__item.is-active {
  color: #000000;
  cursor: pointer;
  background-color: #d3c3a9;
}
::v-deep .el-tabs__item:hover {
  color: #000000;
  cursor: pointer;
  background-color: #d3c3a9;
}

::v-deep .el-tabs__active-bar {
  background-color: #917155;
}
.roll_box {
  /* height: 250px; */
  width: 100%;
}
input {
  border: 1px solid black;
  border-radius: 0px;
  box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
  margin-left: 12px;
}
.ue {
  width: 100%;
  position: fixed;
  top: 0;
  z-index: 1000;
  background-color: #d3c3a9;
}
#te {
  margin-left: 10px;
}
#tt {
  margin-right: -3px;
}
#tp {
  margin-left: 20px;
}
::v-deep .updateTab .el-tabs__header {
  height: 100%;
  width: 283px;
  display: flex;
}
::v-deep .el-tabs--right .el-tabs__nav.is-right {
  flex-direction: row;
  display: flex;
  flex-wrap: wrap;
  /* flex-direction: column-reverse; */
}
::v-deep .el-tabs--right .el-tabs__item.is-right {
  justify-content: flex-start;
  width: 56.42px;
  display: flex;
  align-items: center;
  justify-content: center;
}
::v-deep .van-cell-group {
  margin-top: 12px;
}
.ub {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
}
.jaon {
  display: flex;
}
.tab {
  /* padding: 10px !important; */
  border: 1px solid #ccc !important;
  cursor: pointer !important;
  width: 62px;
  height: auto;
  font-size: 12px;
}

.active {
  background-color: #917155 !important;
  color: #ffffff !important;
}
.jj {
  /* margin-top: 20px;
                           margin-bottom: 20px; */
  /* padding-left: 20px;
                            padding-right: 20px; */
  font-size: 20px;
  height: 32px;
  width: 49px;
  line-height: 16px;
  background-color: #d3c3a9;
  /* background-color: #917155; */
  /* color: #ffffff; */
  /* margin-right: 18px; */
  border: none; /* 去掉边框 */
  color: #573707; /* 文字颜色 */
  /* padding: 15px 32px;  */
  text-align: center; /* 文字居中 */
  text-decoration: none; /* 去掉下划线 */
  display: inline-block; /* 使其成为行内块元素 */
  font-size: 16px; /* 字体大小 */
  cursor: pointer; /* 鼠标悬停时显示指针形状 */
  /* border-radius: 5px; */
  transition: background-color 0.3s, color 0.3s; /* 过渡效果 */
}
.tj {
  margin-top: 20px;
  margin-bottom: 20px;
  /* padding-left: 20px;
                            padding-right: 20px; */
  font-size: 20px;
  height: 50px;
  width: 100px;
  background-color: #917155;
  color: #ffffff;
  margin-right: 18px;
  border: none; /* 去掉边框 */
  color: white; /* 文字颜色 */
  /* padding: 15px 32px;  */
  text-align: center; /* 文字居中 */
  text-decoration: none; /* 去掉下划线 */
  display: inline-block; /* 使其成为行内块元素 */
  font-size: 16px; /* 字体大小 */
  cursor: pointer; /* 鼠标悬停时显示指针形状 */
  border-radius: 5px; /* 圆角边框 */
  transition: background-color 0.3s, color 0.3s; /* 过渡效果 */
}
.tj1 {
  margin-top: 20px;
  margin-bottom: 20px;
  padding-left: 20px;
  padding-right: 20px;
  font-size: 20px;
  height: 50px;
  width: 100px;
  background-color: #917155;
  color: #ffffff;
  margin-left: 18px;
  border: none; /* 去掉边框 */
  color: white; /* 文字颜色 */
  padding: 15px 32px; /* 内边距 */
  text-align: center; /* 文字居中 */
  text-decoration: none; /* 去掉下划线 */
  display: inline-block; /* 使其成为行内块元素 */
  font-size: 16px; /* 字体大小 */
  cursor: pointer; /* 鼠标悬停时显示指针形状 */
  border-radius: 5px; /* 圆角边框 */
  transition: background-color 0.3s, color 0.3s; /* 过渡效果 */
}
.tj2 {
  margin-top: 20px;
  margin-bottom: 20px;
  /* padding-left: 20px;
                            padding-right: 20px; */
  font-size: 20px;
  height: 50px;
  width: 100px;
  background-color: #917155;
  color: #ffffff;
  margin-left: 18px;
  border: none; /* 去掉边框 */
  color: white; /* 文字颜色 */
  /* padding: 15px 32px; */
  text-align: center; /* 文字居中 */
  text-decoration: none; /* 去掉下划线 */
  display: inline-block; /* 使其成为行内块元素 */
  font-size: 16px; /* 字体大小 */
  cursor: pointer; /* 鼠标悬停时显示指针形状 */
  border-radius: 5px; /* 圆角边框 */
  transition: background-color 0.3s, color 0.3s; /* 过渡效果 */
}
.update_tab {
  width: 300px;
  position: fixed;
  right: 0;
  top: 70px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  border: 1px solid black;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
p {
  font-size: 18px;
  color: #000000;
  /* width: 120px; */
  /* margin-right: 10px; */
  text-align: right;
  display: inline-block;
}
.ppp {
  font-size: 12px;
}
@media screen and (orientation: portrait) {
  .portrait {
    /* 竖屏样式 */
  }
  ::v-deep .jj {
    width: 82px;
    height: 50px;
  }
  /* ::v-deep .updateTab .el-tabs__header{
                                height: 100%;
                                width: 249px;
                                display: flex;
                            } */
  ::v-deep .el-tabs--right .el-tabs__item.is-right {
    justify-content: center;
    width: 85px;
    display: flex;
    align-items: center;
    font-size: 22px;
  }
  ::v-deep .con_tit {
    font-size: 24px;
    height: 400px;
  }
  ::v-deep .roll_box {
    height: 450px;
    padding-top: 75px;
  }
  ::v-deep .van-radio__label {
    padding-top: 4px;
    font-size: 24px;
    height: 28px;
  }
  ::v-deep .van-radio {
    margin-top: 36px;
    overflow: inherit;
  }
  ::v-deep .update_right {
    width: calc(100% - 285px);
    height: 100%;
    display: flex;
    justify-content: space-between;
  }
  ::v-deep .update_tab {
    width: 315px !important;
    position: fixed;
    right: 0;
    top: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    border: 1px solid black;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  }
  ::v-deep .update_conten {
    width: 100%;
    height: 16017px;
    overflow-y: hidden;
    padding: 24px 30px;
    box-sizing: border-box;
  }
  .bt {
    flex-direction: column;
  }
  .tj {
    margin-right: 0;
  }
  .tj1 {
    margin-left: 0;
  }
  .pp {
    font-size: 16px;
  }
  a {
    font-size: 16px;
  }
  ::v-deep p {
    font-size: 20px;
  }
  ::v-deep .bsn {
    height: auto;
    padding: 7px 0px;
  }
  ::v-deep .tab {
    height: 40px;
    font-size: 16px;
  }
  ::v-deep .ppp {
    font-size: 18px;
  }
}
</style>
